package com.PTRS.test;

import com.PTRS.dao.IUserDao;
import com.PTRS.entities.User;
import java.util.List;

public class test {

    public static void insert(){
        User user = new User();
        user.setUserID("admin0000");
        user.setUserPasswd("root");
        user.setUserNickname("admin");
        user.setUserSex("ad");
        user.setMember(true);
        user.setUserBalance(100);
        user.setUserEmail("admin");
        user.setUserTel("123456");
        user.setUserAge(12);

        DBHelper helper = new DBHelper();
        IUserDao userDao = helper.init();
        userDao.saveUser(user);
        helper.destory();
    }

    public static void selectAll(){
        DBHelper helper = new DBHelper();
        IUserDao userDao = helper.init();
        List<User> userList = userDao.findAll();
        for (User user : userList){
            System.out.println(user);
        }
        helper.destory();
    }

    public static void delete(){
        DBHelper helper = new DBHelper();
        IUserDao userDao = helper.init();
        userDao.deleteUser("admin0000");
        helper.destory();
    }

    public static void main(String[] args){
        insert();
//        selectAll();
//        delete();
    }
}
